import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

JSONObject json;

void setup() {
  System.setProperty("http.proxyHost", "jpnproxy.jp.ibm.com");
  System.setProperty("http.proxyPort", "8080");
  
  json = loadJSONObject("http://weather.livedoor.com/forecast/webservice/json/v1?city=130010");

  JSONArray forecasts = json.getJSONArray("forecasts");
  JSONObject tommorow = forecasts.getJSONObject(1); 
  
  String telop = tommorow.getString("telop");
  String date  = tommorow.getString("date");

  println("telop " + telop);
  println("date " + date);
  
  String url = tommorow.getJSONObject("image").getString("url");
  println("url " + url);
  
  String min = tommorow.getJSONObject("temperature").getJSONObject("min").getString("celsius");
  String max = tommorow.getJSONObject("temperature").getJSONObject("max").getString("celsius");
  
  println("max-min " + max + "-" + min);
// 日本語  
  
  println("date "+date);

  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
  try {
    Date dt = sdf.parse(date);
    sdf.applyPattern("MMM-d");
    println(sdf.format(dt));
  }catch (Exception e) {
    println("caught e");
    println(e.toString());
  }

 // SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
 // SimpleDateFormat dateFormat = new SimpleDateFormat();
// dateFormat.applyPattern("M-dd");
// println(







//  json.setInt("id", 0);
//  json.setString("species", "Panthera leo");
//  json.setString("name", "Lion");

//  saveJSONObject(json, "data/new.json");
}

// Sketch saves the following to a file called "new.json":
// {
//   "id": 0,
//   "species": "Panthera leo",
//   "name": "Lion"

//130010
/*
http://weather.livedoor.com/forecast/webservice/json/v1?city=130010
*/


